import React, { Component } from 'react'
import './ListCard.css'
// import { connect } from 'react-redux'
import { withRouter } from 'react-router-dom'
import { Card } from 'antd-mobile'

class ListCard extends Component {
   goTo = (path) => {
      return () => {
         this.props.history.push({
            pathname: path,
            state: {targetInfo: this.props.userInfo}
         })
      }
   }
   render() {
      const { header, username, post, info, company, salary, type } = this.props.userInfo
      return (
         <div className='item-card'>
            <Card title={
               <div className='card-header'>
                  <img src={header} alt="" />
                  <span>{username}</span>
               </div>
            } onClick={this.goTo('/chat')} headerStyle={{ padding: '0', width: '100%' }}>
               <div className='card-body'>
                  <p>职位：{post ? post : '待完善'}</p>
                  <p>简介：{info ? info : '待完善'}</p>
                  {type === 'laoban' ? <p>月薪：{salary ? salary : '待完善'}</p> : null}
                  {type === 'laoban' ? <p>公司：{company ? company : '待完善'}</p> : null}
               </div>
            </Card>
         </div>
      )
   }
}

export default withRouter(ListCard)